<?php
namespace app\admin\logic;


//品牌页
use think\facade\Request;

class BrandLogic{
    //brand品牌留值处理
    public static function brandData(){
        $param=Request::param();
        $data=[
            'keywords'=>isset($param['keywords'])?$param['keywords']:'',
            'recommended'=>isset($param['recommended'])?$param['recommended']:'',
            'if_show'=>isset($param['if_show'])?$param['if_show']:[],
            'logo'=>isset($param['logo'])?$param['logo']:[],
        ];
        return $data;
    }

    //brand品牌列表 where条件拼接
    public static function brandWhere(){
        $where=[];
        $whereOr=[];
        $param=Request::param();
        if (isset($param['keywords']) && !empty($param['keywords'])){
            $where[]=['brand_name','like','%'.$param['keywords'].'%'];
        }
        if (isset($param['recommended']) && $param['recommended']<>''){
            $where[]=['recommended','=',$param['recommended']];
        }
        if (isset($param['if_show']) && count($param['if_show'])=='1'){
            $where[]=['if_show','in',$param['if_show']];
        }
        if (isset($param['logo']) && count($param['logo'])=='1'){
            if ($param['logo'][0]=='1'){
                $where[]=['brand_logo','<>',''];
            }else if ($param['logo'][0]=='0'){
                $whereOr[]=['brand_logo','=',''];
                $whereOr[]=['brand_logo','=',null];
            }
        }
        return [$where,$whereOr];
    }


}